#include <stdio.h>
#include <stdlib.h>
#include "japi.h"

int main()
{
    char name[100];
    char password[100];

    if(j_start()<0)
    {
        printf("can't connect to server\n");
        exit(0);
    }

    int obj;
    int frame     = j_frame("Textfield Test");
    int login    = j_textfield(frame,35);
    int passwd   = j_textfield(frame,35);
    int nameLabel = j_label(frame, "UserName:");
    int passLabel = j_label(frame, "Password:");

    j_setechochar(passwd,'*');

    j_setpos(nameLabel,10, 50);
    j_setpos(passLabel,10, 100);

    j_setpos(login, 100, 50);
    j_setpos(passwd, 100, 100);

    j_show(frame);

    while(1)
    {
        obj=j_nextaction();

        if(obj==frame)
        {
            break;
        }

        if(obj==login)
        {
            j_gettext(login,name);
            printf("Your name is %s\n",name);
        }

        if(obj==passwd)
        {
            j_gettext(passwd,password);
            printf("Your password is %s\n",password);
        }
    }


    printf("Hello world!\n");
    return 0;
}
